from typing import Dict, List, Optional, Any, Union
from pydantic import BaseModel, Field

class QueryRequest(BaseModel):
    query: str = Field(...)

class ChartConfigRequest(BaseModel):
    data: List[Dict[str, Any]] = Field(...)
    query: str = Field(...)
    chart_type: Optional[str] = Field(None)

class QueryResponse(BaseModel):
    sql: str = Field(...)
    data: Optional[List[Dict[str, Any]]] = Field(None)
    chart_config: Dict[str, Any] = Field(...)

class ErrorResponse(BaseModel):
    error: str = Field(...)
    detail: Optional[str] = Field(None)

class ApiResponse(BaseModel):
    success: bool = Field(...)
    data: Optional[Any] = Field(None)
    error: Optional[str] = Field(None)